package me.leoray.logger;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;

import me.leoray.leilog.Logger;
import me.leoray.leilog.Logs;
import me.leoray.leilog.Settings;

public class MainActivity extends Activity {
    private static final String TAG = "MainActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);
        //默认配置
        Logger.settings().logBox().method(4).showThreadInfo();
        //特殊配置
        final Settings dummy = Settings.of("Dummy");
//        dummy.logSimple();
        Logger.get().settings("me.leoray.logger.F", dummy);
        Logger.settings("me.leoray.logger.Fo", "Foo").logDetail().hideThreadInfo().method(0);
        Logger.d("hello my logger");
        Logger.e("error");
        for (int i = 0; i < 1; i++) {
            final int finalI = i;
            new Thread(new Runnable() {
                @Override
                public void run() {
                    StringBuilder builder = new StringBuilder();
                    for (int j = 0; j < 200; j++) {
                        builder.append(finalI);
                    }
                    Logger.d(builder.toString());
                }
            }).start();
        }
        Logs.get().json(Dummy.JSON_WITH_NO_LINE_BREAK);
        Logger.settings().openLogSave(this, Log.DEBUG);
        Logger.e("error 2");
        Logs.get().xml(Dummy.XML_TEMPLATE);
        Logs.get("myTag").w("singleTag", "hello%s world%s,%s", 1, "2", new Foo());
        Logs.get("detail").settings().logDetail();
        Logs.get("detail").i("libai");
        Foo.foo();

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);

        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}
